package message

import "github.com/go-playground/validator/v10"

type MessageSendToUserReq struct {
	To      int64  `json:"to"`
	Type    string `json:"type" binding:"required"`
	Content string `json:"content" binging:"required"`
}

func (MessageSendToUserReq) GetErr(err error) string {
	_, ok := err.(validator.ValidationErrors)
	if ok {
		for _, e := range err.(validator.ValidationErrors) {
			if e.Field() == "To" {
				return "接收人不能为空"
			}
			if e.Field() == "Type" {
				return "消息类型不能为空"
			}
			if e.Field() == "Content" {
				return "消息内容不能为空"
			}
		}
	}
	return "参数错误"
}

type MessageSendToGroupReq struct {
	Type    string `json:"type" binding:"required"`
	Content string `json:"content" binging:"required"`
}

func (MessageSendToGroupReq) GetErr(err error) string {
	_, ok := err.(validator.ValidationErrors)
	if ok {
		for _, e := range err.(validator.ValidationErrors) {
			if e.Field() == "Type" {
				return "消息类型不能为空"
			}
			if e.Field() == "Content" {
				return "消息内容不能为空"
			}
		}
	}
	return "参数错误"
}
